package com.peakmain.systemmoudle.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.peakmain.systemmoudle.bean.FragmentInfo;

import java.util.List;

/**
 * author: peakmain
 * createdata：2019/7/16
 * mail: 2726449200@qq.com
 * desiption:
 */
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
    private List<FragmentInfo> fragmentInfos;

    public ViewPagerAdapter(FragmentManager fm, List<FragmentInfo> fragmentInfoList) {
        super(fm);
        this.fragmentInfos = fragmentInfoList;
    }

    @Override
    public Fragment getItem(int position) {

        return fragmentInfos.get(position).getFragment();

    }

    @Override
    public int getCount() {
        return fragmentInfos.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return fragmentInfos.get(position).getTitle();
    }
}
